<?php 

	/**
	 * 微官网控制器
	 * @author Administrator
	 *
	 */
	class IndexAction extends Action
	{

		public function Index()
		{	
			echo "禁止访问404";
			echo "<br/>";
			echo '你的IP以被记录';
			echo $_SERVER['REMOTE_ADDR'];
			die();
			//$this->display();
		}

		public function dologin()
		{
			//过滤请求数组
			$requestArr = common_html_Arr($_POST);
			
			//校验用户名
			if ( $requestArr['key'] == NULL )
			{
				//响应信息
				$this->error('钥匙不能为空', '/');		
				
			}
			//实例化model
			$keyjhmModel = new KeyjhmModel();
			
			
			$result = $keyjhmModel->checkLogin($requestArr['key']);
			//echo md5('85951314aa12');die();
			//P($result);die();
         	 //判断登录
			if ( $result['ifsort'] == 0 ) {
				//响应信息
				$this->error('秘钥禁止登录', '/');
			}
			//限制登录次数
			if ( $result['isdl'] > '10' ) {
				//响应信息
				$this->error('秘钥登录次数过多', '/');
			}
			if ( $result > 0)
			{

				//die(P($result));
				//判断是否第一次登录
				if ($result['isdl']==0) {
					//添加时间和登录次数
					$result['addtime'] = date('Y-m-d H:i:s',time());
					$result['isdl'] = $result['isdl']+1;
					$result['dy_ip'] = $_SERVER['REMOTE_ADDR'];
					$keyjhmModel->update($result,$result['id']);
					
				}else{
					$result['isdl'] = $result['isdl']+1;
					$result['dr_time'] = date('Y-m-d H:i:s',time());
					$result['zh_ip'] = $_SERVER['REMOTE_ADDR'];
					$keyjhmModel->update($result,$result['id']);
					
				}
				//die();
				//保存登录信息$result['username']
				$_SESSION['jhm']['id'] =  $result['id'];

				$this->success('验证成功', '/Jhmkey/index');
				
			}
			else
			{
				//响应信息
				$this->error('钥匙错误', '/');
				
			}

		}
}